package com.swt.controller;

import com.swt.common.utils.QiNiuYunUpFileUtils;
import com.swt.common.vo.ResponseVo;
import com.swt.domain.GoodsComment;
import com.swt.service.GoodsCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description
 * @Author swt
 * @Date 2022/5/17
 */
@RestController
@RequestMapping("/GoodsComment")
public class GoodsCommentController {
    @Autowired
    public GoodsCommentService goodsCommentService;
    @PostMapping("/{count}/{size}")
    public ResponseVo pageGoodsComment(@PathVariable Integer count,
                                       @PathVariable Integer size,
                                       @RequestBody GoodsComment goodsComment){
        return ResponseVo.SUCCESS(goodsCommentService.pageGoodsComment(count,size,goodsComment));

    }
    @DeleteMapping("/{id}")
    public ResponseVo DeleteGoodsComment(@PathVariable String id){
        return goodsCommentService.delectGoodsComment(id)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @GetMapping("/{id}")
    public ResponseVo selectGoodCommentById(@PathVariable String id){
        return ResponseVo.SUCCESS(goodsCommentService.selectbyGoodsCommentid(id));
    }
    @PostMapping
    public ResponseVo InSerGoodsComment(@RequestBody GoodsComment s){
        return goodsCommentService.inserGoodsComment(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PutMapping
    public ResponseVo updateGoodsComment(@RequestBody GoodsComment s){
        return goodsCommentService.updateGoodsComment(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PostMapping("/upload")
    public ResponseVo upLoadGoodsCommentImg(MultipartFile file){
        System.out.println(file);
        return QiNiuYunUpFileUtils.getUpLoad(file);
    }
}

